package day0515;

import java.util.Arrays;

class Soldier{}
class GloryGame{
    Soldier []   ss={};
    void createSoldiersAction(){
        ss= Arrays.copyOf(ss,  ss.length+1);//对数组扩容
        ss[ ss.length-1 ]=new Soldier();//创建新的Soldier对象从存入到ss数组的最后一位。
        for (int i = 0; i < ss.length; i++) {
            System.out.print(i +", ");
        }
        System.out.println();
    }
}

public class TestGame {
    public static void main(String[] args) throws InterruptedException {
        //循环调用createSoldiersAction() 并打印数组的每个元素的序号
        GloryGame g=new GloryGame();
        while(true){
            g.createSoldiersAction();
            Thread.sleep(1000);
        }
    }
}
